using EOSDigital.SDK;
using System;
using System.Runtime.Serialization;

namespace EOSDigital.API
{
	[Serializable]
	public sealed class SDKException : Exception
	{
		public ErrorCode Error
		{
			get;
			private set;
		}

		public SDKException()
		{
			this.Error = ErrorCode.INTERNAL_ERROR;
		}

		public SDKException(ErrorCode Error)
			: base(Error.ToString())
		{
			this.Error = Error;
		}

		public SDKException(string message)
			: base(message)
		{
			this.Error = ErrorCode.INTERNAL_ERROR;
		}

		public SDKException(string message, Exception innerException)
			: base(message, innerException)
		{
			this.Error = ErrorCode.INTERNAL_ERROR;
		}

		public SDKException(string message, ErrorCode Error)
			: base(message)
		{
			this.Error = Error;
		}

		public SDKException(string message, ErrorCode Error, Exception innerException)
			: base(message, innerException)
		{
			this.Error = Error;
		}

		private SDKException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
			this.Error = (ErrorCode)info.GetUInt32("Error");
		}

		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			if (info == null)
			{
				throw new ArgumentNullException("info");
			}
			info.AddValue("Error", this.Error);
			base.GetObjectData(info, context);
		}
	}
}
